package com.ruoyi.zyx.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zyx.domain.ZyxAllot;
import com.ruoyi.zyx.service.IZyxAllotService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调拨信息Controller
 * 
 * @author lhs
 * @date 2021-06-07
 */
@RestController
@RequestMapping("/zyx/allot")
public class ZyxAllotController extends BaseController
{
    @Autowired
    private IZyxAllotService zyxAllotService;

    /**
     * 查询调拨信息列表
     */
    @PreAuthorize("@ss.hasPermi('zyx:allot:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZyxAllot zyxAllot)
    {
        startPage();
        List<ZyxAllot> list = zyxAllotService.selectZyxAllotList(zyxAllot);
        return getDataTable(list);
    }

    /**
     * 导出调拨信息列表
     */
    @PreAuthorize("@ss.hasPermi('zyx:allot:export')")
    @Log(title = "调拨信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZyxAllot zyxAllot)
    {
        List<ZyxAllot> list = zyxAllotService.selectZyxAllotList(zyxAllot);
        ExcelUtil<ZyxAllot> util = new ExcelUtil<ZyxAllot>(ZyxAllot.class);
        return util.exportExcel(list, "调拨信息数据");
    }

    /**
     * 获取调拨信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('zyx:allot:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zyxAllotService.selectZyxAllotById(id));
    }

    /**
     * 新增调拨信息
     */
    @PreAuthorize("@ss.hasPermi('zyx:allot:add')")
    @Log(title = "调拨信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZyxAllot zyxAllot)
    {
        return toAjax(zyxAllotService.insertZyxAllot(zyxAllot));
    }

    /**
     * 修改调拨信息
     */
    @PreAuthorize("@ss.hasPermi('zyx:allot:edit')")
    @Log(title = "调拨信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZyxAllot zyxAllot)
    {
        return toAjax(zyxAllotService.updateZyxAllot(zyxAllot));
    }

    /**
     * 删除调拨信息
     */
    @PreAuthorize("@ss.hasPermi('zyx:allot:remove')")
    @Log(title = "调拨信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zyxAllotService.deleteZyxAllotByIds(ids));
    }
}
